﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.ObjectFactory;
using YasharEl.Infrastructure.Caching.Orm;

namespace YasharEl.Infrastructure.Caching.Configuration
{
    public partial class OrmCacheManagerConfig
    {
        public override ICacheManager CreateCacheManager(IDependencyRegistrar dependencyRegistrar)
        {
            try
            {
                IOrmCacheManagerFactory cacheManagerFactory = (IOrmCacheManagerFactory)Activator.CreateInstance(CacheManagerFactory);
                return cacheManagerFactory.CreateAndRegisterCacheManager(this, dependencyRegistrar);
            }
            catch (Exception e)
            {
                throw new InvalidSystemConfigurationException(string.Format("Could not recognize orm cache factory {0}", CacheManagerFactory.FullNameToString()), e);
            }
        }
    }
}
